home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 July / com!online0702.iso / software / livemotion / DATA1.CAB / Scripting_Resources / Samples / Automation_Scripts / Make Alias.js < prev    next >
Encoding:
Text File  |  2002-05-13  |  2.9 KB  |  87 lines

  1. //////////////////////////////////////////////////
  2. //
  3. // ADOBE SYSTEMS INCORPORATED 
  4. // Copyright 2002 Adobe Systems Incorporated 
  5. // All Rights Reserved 
  6. //
  7. // NOTICE:  Adobe permits you to use, modify, and 
  8. // distribute this file in accordance with the terms
  9. // of the Adobe license agreement accompanying it.  
  10. // If you have received this file from a source 
  11. // other than Adobe, then your use, modification,
  12. // or distribution of it requires the prior 
  13. // written permission of Adobe. 
  14. //
  15. //////////////////////////////////////////////////
  16.  
  17. //////////////////////////////////////////////////
  18. // Make Alias.js
  19. // 
  20. // DESCRIPTION
  21. //
  22. // This script demonstrates the use of any functions of a class.
  23. // Here the method used is makeAlias which creates an alias of the
  24. // currently selected object. The advantage of using an alias is 
  25. // that an alias exports as a single object with multiple references.
  26. // 
  27. // HOW TO USE
  28. //
  29. // Create any object and select it in the Composition.
  30. // Select Scripts > Make Alias
  31. // Change the original or alias of the object and the 
  32. // changes will be reflected in both of them.
  33. //
  34. //////////////////////////////////////////////////
  35.  
  36. // Main Code [Execution of script begins from here]
  37.  
  38. // Check if any composition is open
  39. if(application.compositions.length > 0){
  40.     comp = application.currentComposition;
  41.     if(comp.selection.length >= 1){ // Checks if at least one object is selected
  42.         var targets = comp.selection; // Store all selected objects in the array targets
  43.         
  44.         // saves the current selection
  45.         application.currentComposition.saveSelection(); 
  46.         createAlias(targets);// Function createAlias called
  47.          
  48.          // restores the saved selection
  49.         application.currentComposition.restoreSelection();
  50.     }
  51.     else{ // If no objects are selected brings the Console window up 
  52.         Console.show();
  53.         // Writes to the Console
  54.         Console.write("Please select the objects to make alias of and run script again.\n");
  55.     }
  56. }
  57. else{// if no composition open
  58.     // opens a new composition
  59.     comp = application.newComposition();
  60.     Console.show();
  61.     Console.write("New Composition opened\nPlease create and select the objects to make alias of and run script again.\n");
  62. }
  63.  
  64.  
  65. // Add your own functions here
  66.  
  67. //////////////////////////////////////////////////
  68. // createAlias:
  69. // Creates an alias of the objects passed to it
  70. //
  71. // The Alias will be created on top of the original object
  72. // Drag it away from the top and try to change it to see
  73. // changes reflected in both the source as well as target
  74.  
  75. // source: The currently selected objects which are passed
  76. // to the function
  77. //////////////////////////////////////////////////
  78.  
  79. function createAlias(source)
  80. {
  81.     var aliases = new Array();// Array to store new alias
  82.     for(var i=0; i < source.length ; i++) {
  83.         aliases[i] = source[i].makeAlias();//method makeAlias creates the alias
  84.     }
  85. }
  86.  
  87.